package com.prim.background;

public class MultiThreadError8 implements Runnable {
    int index = 0;
    static MultiThreadError8 instance = new MultiThreadError8();

    public static void main(String[] args) throws InterruptedException {
        Thread thread1 = new Thread(instance);
        Thread thread2 = new Thread(instance);
        thread1.start();
        thread2.start();
        thread1.join();//等待线程1执行完毕
        thread2.join();//等待线程2执行完毕
        System.out.println(instance.index);
    }

    @Override
    public void run() {
        for (int i = 0; i < 10000; i++) {
            index++;
        }
    }
}
